package com.entity;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * ThirdCategory entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "third_category", catalog = "dangdang")
public class ThirdCategory implements java.io.Serializable {

	// Fields
	private static final long serialVersionUID = 1L;
	private Integer id;
	private SecondCategory secondCategory;
	private String name;
	private Set<Product> products = new HashSet<Product>(0);

	// Constructors

	/** default constructor */
	public ThirdCategory() {
	}

	/** minimal constructor */
	public ThirdCategory(SecondCategory secondCategory, String name) {
		this.secondCategory = secondCategory;
		this.name = name;
	}

	/** full constructor */
	public ThirdCategory(SecondCategory secondCategory, String name,
			Set<Product> products) {
		this.secondCategory = secondCategory;
		this.name = name;
		this.products = products;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "parent_id", nullable = false)
	public SecondCategory getSecondCategory() {
		return this.secondCategory;
	}

	public void setSecondCategory(SecondCategory secondCategory) {
		this.secondCategory = secondCategory;
	}

	@Column(name = "name", nullable = false, length = 200)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "thirdCategory")
	public Set<Product> getProducts() {
		return this.products;
	}

	public void setProducts(Set<Product> products) {
		this.products = products;
	}

}